-
Notifications
You must be signed in to change notification settings - Fork 11.9k
Modernize Webpack/Karma builder architecture #32194
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
clydin
wants to merge
11
commits into
angular:main
Choose a base branch
from
clydin:karma/cleanup
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
+180
−237
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…ncIterable Refactor the Karma builder's `execute` function to return an `AsyncIterable` using a `ReadableStream`. This removes the RxJS dependency and aligns the builder with modern Angular CLI implementation patterns. Additionally, this change fixes a race condition where the Karma server could start even if the builder was cancelled during asynchronous initialization. An `isCancelled` flag is now used to ensure execution stops if a cancellation occurs before the server starts.
…webpack plugin callbacks Decouples the Karma builder from the Webpack plugin by removing the custom `successCb` and `failureCb` callback mechanism. The builder now idiomaticallly listens to the standard Karma `run_complete` event on the server instance to emit builder results.
…to AsyncIterable Refactor the Karma builder's main `execute` function to return an `AsyncIterable` instead of an RxJS `Observable`. This continues the effort to reduce RxJS usage in the CLI builders and aligns the implementation with modern Angular CLI patterns.
… builder Refactor the Karma builder's `execute` function to directly handle dynamic imports within conditional blocks. This eliminates the need for `getExecuteWithBuilder` and the resulting union types that required `as any` casting. This improves type safety by allowing TypeScript to verify the arguments passed to the specific builder implementations (Esbuild vs Webpack).
cff3b04 to
49c3813
Compare
… API for karma builder Adds an `executeKarmaBuilder` wrapper function in the package entry point that returns an RxJS `Observable`. This maintains backward compatibility for the experimental public API while the internal implementation has been migrated to use `AsyncIterable`.
…on to karma builder Moves the instantiation of the Webpack Compiler from the Karma plugin to the Karma builder (`browser_builder`). This allows the builder to have full ownership of the compiler's lifecycle and configuration, including `singleRun` adjustments and output paths. The Karma plugin now receives the `compiler` instance directly instead of the configuration, reducing its responsibility to just integration logic.
…rom karma plugin Removes the `createConsoleLogger` import and its usage as a fallback in the Karma plugin. The logger is now consistently provided by the builder via the `buildWebpack` configuration object.
Consolidates the compiler hooks in the Karma plugin. Merges separate `compiler.hooks.done` taps into a single unified handler that manages error reporting, file refreshing, and blocking logic.
…ter from karma plugin Removes the `@angular-devkit/build-angular--event-reporter` and its logic. The reporter was no longer performing significant work after the removal of custom callbacks, and its primary remaining function was a logging hack that is no longer required.
…nup karma middleware Updates the `requestBlocker` and `fallbackMiddleware` functions in the Karma plugin to use strict `IncomingMessage`, `ServerResponse`, and `NextFunction` types from `node:http`. Also properly types the `webpackMiddleware` variable and ensures its `close` method is called with a callback in the exit handler, resolving a TypeScript error exposed by the stricter typing.
…cker from karma plugin Removes the custom request blocker middleware and related hooks from the Karma plugin. `webpack-dev-middleware` already handles blocking requests until compilation is valid, making this custom logic redundant and unnecessary.
49c3813 to
889390a
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
action: review
The PR is still awaiting reviews from at least one requested reviewer
area: @angular-devkit/build-angular
target: minor
This PR is targeted for the next minor release
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR refactors the Karma builder in
@angular-devkit/build-angularto modernize its architecture, reduce technical debt, and improve type safety. The primary goals were to remove RxJS dependencies from the builder's core execution flow, decouple the builder from the Webpack/Karma plugin, and centralize the build configuration and lifecycle management within the builder itself.See individual commits for more details.